package com.itheima;

import com.itheima.eurekafeignclient.service.FeignService;
import com.itheima.eurekafeignclient.service.FeignServiceStudent;
import entity.Animal;
import entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
import java.util.Map;

@RestController
public class FeignController {
    @Autowired
    FeignService feignService;
    @Autowired
    FeignServiceStudent feignServiceStudent;

    // 现有接口
    @RequestMapping(value = "/hello01", method = RequestMethod.GET)
    public String hello1() {
        return feignService.sayHello();
    }

    // 新增接口 - Student
    @RequestMapping(value = "/hello02", method = RequestMethod.GET)
    public String hello2() {
        ResponseEntity<Student> response = feignServiceStudent.getStudent();
        Student body = response.getBody();
        return body.toString();
    }

    // 新增接口 - Animal
    @RequestMapping(value = "/hello03", method = RequestMethod.GET)
    public String hello3() {
        ResponseEntity<Animal> response = feignService.getAnimal();
        Animal body = response.getBody();
        return body.toString();
    }
}